package top.hcode.hoj.service.oj;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.hcode.hoj.mapper.TagClassificationMapper;
import top.hcode.hoj.mapper.TagMapper;
import top.hcode.hoj.pojo.entity.problem.Tag;
import top.hcode.hoj.pojo.entity.problem.TagClassification;

import java.util.List;

/**
 * @author orangej
 * @since 2024/12/17
 */
@Component
public class TagService {
    @Autowired
    private TagMapper tagMapper;

    @Autowired
    private TagClassificationMapper tagClassificationMapper;

    public List<TagClassification> getTagClassification() {
        QueryWrapper<TagClassification> query = new QueryWrapper<>();
        query.select("id", "name");
        query.orderByAsc("`rank`");
        return tagClassificationMapper.selectList(query);
    }

    public List<Tag> getTagList() {
        QueryWrapper<Tag> query = new QueryWrapper<>();
        query.select("id", "name", "color", "tcid", "parent_id", "is_leaf");
        query.eq("enabled", true);
        return tagMapper.selectList(query);
    }
}
